package com.kwok.boot.rabbitmq.workqueues.producer.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class ProducerController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/send")
    public String sendMessageToQueue(String message) {
        log.debug("生产者发送到队列中的消息数据是：{}", message);
        rabbitTemplate.convertAndSend("Work-Queues", message);
        return "消息发送成功";
    }

}
